package com.example.xjtuse_pc.mobilesafe.LostGuid;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.example.xjtuse_pc.mobilesafe.R;

public class Setup3Activity extends BaseSetupAcitivity {
    private EditText et_setup3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setup3);
        et_setup3= (EditText) findViewById(R.id.et_setup3);
        et_setup3.setText(sp.getString("safephone",""));
    }

    @Override
    public void showNext() {
        String phone=et_setup3.getText().toString().trim();
        if(TextUtils.isEmpty(phone)){
            Toast.makeText(Setup3Activity.this, "安全账号未设置", Toast.LENGTH_SHORT).show();
            return;
        }
        SharedPreferences.Editor editor=sp.edit();
        editor.putString("safephone",phone);
        editor.commit();
        Intent intent = new Intent(Setup3Activity.this, Setup4Activity.class);
        startActivity(intent);
        finish();
        overridePendingTransition(R.anim.tran_in, R.anim.tran_out);
    }

    @Override
    public void showPre() {
        Intent intent = new Intent(Setup3Activity.this, Setup2Activity.class);
        startActivity(intent);
        finish();
        overridePendingTransition(R.anim.retran_in, R.anim.retran_out);
    }
    public void SelectNumber(View view) {
        Intent intent =new Intent(Setup3Activity.this,PhontNumberActivity.class);
        startActivityForResult(intent, 0);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==0){
            String phone=data.getStringExtra("phone").replace("-", "").trim();
            et_setup3.setText(phone);
            Log.i("join", "获取的手机号" + phone);
        }
    }
}
